package com.kpiJavaTraining.bogdan.module2;

import java.io.DataOutputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.OutputStream;

/**
 * Class writes a line in a file
 * @author Bogdan Olexandr
 */
public class FileWriter {

	private OutputStream stream;
	private DataOutputStream data;
	private final String PATH ;

	public FileWriter(String path) throws FileNotFoundException{
		PATH = path;
		stream = new FileOutputStream(PATH,true);
		data = new DataOutputStream(stream);
	}
	
	/**
	 * method writes a line in a file
	 * @param argument
	 * @throws IOException
	 */
	public void write(String argument) throws IOException{
		data.writeUTF(argument);		
	}
	
	/**
	 * method closes FileWriter
	 * @throws IOException
	 */
	public void close() throws IOException{
		data.flush();
		data.close();
	}
}
